package com.wutuo.tag.provider.dao;

import cn.apestar.core.base.GenericMapper;
import cn.apestar.core.base.MapperAnnotation;
import com.wutuo.tag.provider.domain.TagRelations;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * 服务关系表 Dao 层
 *
 * @author lvh
 * @version 1.0
 */

@MapperAnnotation public interface BaseTagRelationsMapper
    extends GenericMapper<TagRelations, Long> {
    @Override @Delete({"delete from tag_relations", "where id = #{id,jdbcType=BIGINT}"})
    int deleteByPrimaryKey(Long id);

    @Override
    @Insert({"insert into tag_relations (", "roster_id,", "tag_id,", "create_by,", "create_date,",
        "update_by,", "update_date,", "remarks,", "del_flag", " )values(",
        "#{rosterId,jdbcType=BIGINT},", "#{tagId,jdbcType=BIGINT},", "#{createBy,jdbcType=BIGINT},",
        "#{createDate,jdbcType=DATE},", "#{updateBy,jdbcType=BIGINT},",
        "#{updateDate,jdbcType=DATE},", "#{remarks,jdbcType=VARCHAR},",
        "#{delFlag,jdbcType=VARCHAR})"}) int insert(TagRelations record);

    @InsertProvider(type = BaseTagRelationsSqlProvider.class, method = "insertSelective")
    int insertSelective(TagRelations record);

    @Override
    @Select({"select", "roster_id,", "tag_id,", "create_by,", "create_date,", "update_by,",
        "update_date,", "remarks,", "del_flag", "from tag_relations",
        "where id = #{id,jdbcType=BIGINT}"})
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
        @Result(column = "roster_id", property = "rosterId", jdbcType = JdbcType.BIGINT),
        @Result(column = "tag_id", property = "tagId", jdbcType = JdbcType.BIGINT),
        @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.DATE),
        @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.BIGINT),
        @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.DATE),
        @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
        @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.VARCHAR)})
    TagRelations selectByPrimaryKey(Long id);

    @Override
    @UpdateProvider(type = BaseTagRelationsSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TagRelations record);

    @Override @Update({"update tag_relations", "set ", "roster_id = #{rosterId,jdbcType=BIGINT},",
        "tag_id = #{tagId,jdbcType=BIGINT},", "create_by = #{createBy,jdbcType=BIGINT},",
        "create_date = #{createDate,jdbcType=DATE},", "update_by = #{updateBy,jdbcType=BIGINT},",
        "update_date = #{updateDate,jdbcType=DATE},", "remarks = #{remarks,jdbcType=VARCHAR},",
        "del_flag = #{delFlag,jdbcType=VARCHAR}", "where id = #{id,jdbcType=BIGINT}"})
    int updateByPrimaryKey(TagRelations record);
}